<template>
  <div class="user-introduce">
    <h2>个人资料</h2>
    <el-form :model="form" label-width="100px" style="max-width: 600px">
      <!-- 基本信息 -->
      <h3>基本信息</h3>
      <!-- 头像居中 -->
      <el-form-item label="" prop="avatar" style=" margin-left: 150px; margin-bottom: 20px;" >
        <el-avatar :size="80" :src="circleUrl" />
      </el-form-item>
      <el-form-item label="用户名" prop="username" required>
        <el-input
          v-model="form.username"
          placeholder="请输入用户名"
          maxlength="20"
          show-word-limit
        />
      </el-form-item>

      <el-form-item label="性别" prop="sex" required>
        <el-select v-model="form.sex" placeholder="请选择性别" >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <!-- 手机号 -->
      <el-form-item label="手机号" prop="phone" required>
        <el-input
          v-model="form.phone"
          placeholder="请输入手机号"
          maxlength="11"
          show-word-limit
        />
      </el-form-item>
      <!-- 邮箱 -->
      <el-form-item label="邮箱" prop="email" required>
        <el-input
          v-model="form.email"
          placeholder="请输入邮箱"
          maxlength="50"
          show-word-limit
        />
      </el-form-item>
      <!-- 出生年月日 -->
      <el-form-item label="出生日期" prop="date">
        <el-date-picker
          style="width: 600px"
          v-model="form.date"
          placeholder="选择日期"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD" 9
          :disabled-date="(time) => time.getTime() > Date.now()"
        />
      </el-form-item>
      <!-- 社交媒体 -->
      <el-form-item label="社交媒体" prop="socialMedia">
        <el-input
          v-model="form.socialMedia"
          placeholder="请输入社交媒体账号"
          maxlength="50"
          show-word-limit
        />
      </el-form-item>
      <!-- 所在地点 -->
      <el-form-item label="所在地点" prop="location">
        <el-input
          v-model="form.location"
          placeholder="请输入所在地点"
          maxlength="50"
          show-word-limit
        />
      </el-form-item>
      <el-form-item label="个人介绍" prop="introduction">
        <el-input
          v-model="form.introduction"
          type="textarea"
          placeholder="请填写职业技能、擅长的事情、兴趣爱好等"
          maxlength="100"
          show-word-limit
          :rows="4"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">保存</el-button>
        <el-button @click="onReset">重置</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";

// 表单数据
const form = reactive({
  id: "",
  username: "",
  sex: "",
  date: "",
  location: "",
  socialMedia: "",
  introduction: "",
  avatar: "",
  phone: "",
});
// 头像
const circleUrl = ref("https://p26-passport.byteacctimg.com/img/user-avatar/349270a573badebe73096ca0c5d88661~150x150.awebp");
const options = reactive([
  { value: 0, label: "男" },
  { value: 1, label: "女" },
]);
const onSubmit = () => {
};
</script>

<style scoped>
.user-introduce {
  width: 100%;
  max-width: 600px;
  padding: 20px;
  border: #d9d9d9 1px solid;
  border-radius: 6px;
  background-color: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

h2 {
  margin-bottom: 20px;
  font-size: 20px;
}

h3 {
  margin-top: 30px;
  margin-bottom: 10px;
  font-size: 16px;
}

.el-form-item {
  margin-bottom: 20px;
}

.avatar-upload {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}

.avatar-uploader .avatar {
  width: 100px;
  height: 100px;
  display: block;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 100px;
  height: 100px;
  line-height: 100px;
  text-align: center;
}

.upload-tips {
  text-align: center;
  font-size: 14px;
  color: #606266;
}

.input-new-tag {
  width: 90px;
  vertical-align: bottom;
}
</style>
